import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig(({ command, mode }) => {
  const isDev = mode === 'development';
  
  return {
    plugins: [react()],
    server: {
      host: '0.0.0.0',
      port: 13130,
      cors: true,
      proxy: isDev ? {
        '/rtc': {
          target: 'https://facecheck.ddcoder.laozhan-qiqi-duoduo.space',
          changeOrigin: true,
          secure: true,
          rewrite: (path) => path.replace(/^\/rtc/, '/rtc'),
          headers: {
            'Origin': 'https://facecheck.ddcoder.laozhan-qiqi-duoduo.space'
          }
        },
        '/webrtc': {
          target: 'https://facecheck.ddcoder.laozhan-qiqi-duoduo.space',
          changeOrigin: true,
          secure: true,
          ws: true, // 支持WebSocket
          headers: {
            'Origin': 'https://facecheck.ddcoder.laozhan-qiqi-duoduo.space'
          }
        }
      } : {}
    }
  };
}); 